<div nz-row class="item">
  <div nz-col nzSpan="22"></div>
  <div nz-col nzSpan="2">
    <button nz-button nzType="primary" (click)="showModal()">添加</button>
  </div>
</div>
<nz-table #basicTable [nzData]="list">
  <thead>
  <tr>
    <th>id</th>
    <th>是否为超级管理员</th>
    <th>昵称</th>
    <th>电话</th>
    <th>邮箱</th>
    <th>角色id</th>
    <th>角色名称</th>
    <th>角色备注</th>
    <th>操作</th>
  </tr>
  </thead>
  <tbody>
  <tr *ngFor="let item of list">
    <td>{{ item._id }}</td>
    <td>{{ item.is_super }}</td>
    <td>{{ item.username }}</td>
    <td>{{ item.mobile }}</td>
    <td>{{ item.email }}</td>
    <td>{{ item.role_id }}</td>
    <td>{{ item.role[0].title }}</td>
    <td>{{ item.role[0].description }}</td>
    <td>
      <button nz-button nzType="primary" (click)="showModal(item)">修改</button>
      <button nz-button nzDanger nz-popconfirm
              nzPopconfirmTitle="Are you sure delete this task?"
              nzPopconfirmPlacement="bottom"
              (nzOnConfirm)="confirm(item._id)"
              (nzOnCancel)="cancel()">删除
      </button>
    </td>
  </tr>
  </tbody>
</nz-table>
<nz-drawer
  [nzClosable]="false"
  [nzVisible]="visible"
  nzPlacement="right"
  [nzTitle]="edit._id ? '管理员信息修改' : '管理员信息添加'"
  [nzWidth]="600"
  (nzOnClose)="close()"
>
  <div nz-row class="item">
    <div nz-col nzSpan="2">昵称：</div>
    <div nz-col nzSpan="22"><input nz-input placeholder="Basic usage" [(ngModel)]="edit.username"
                                   [disabled]="edit._id ? true : false"/></div>
  </div>
  <div nz-row class="item">
    <div nz-col nzSpan="2">密码：</div>
    <div nz-col nzSpan="22"><input nz-input placeholder="Basic usage" [(ngModel)]="edit.password"/></div>
  </div>
  <div nz-row class="item">
    <div nz-col nzSpan="2">邮箱：</div>
    <div nz-col nzSpan="22"><input nz-input placeholder="Basic usage" [(ngModel)]="edit.email"/></div>
  </div>
  <div nz-row class="item">
    <div nz-col nzSpan="2">电话：</div>
    <div nz-col nzSpan="22"><input nz-input placeholder="Basic usage" [(ngModel)]="edit.mobile"/></div>
  </div>
  <div nz-row class="item">
    <div nz-col nzSpan="6">是否为超级管理员：</div>
    <div nz-col nzSpan="18">
      <nz-radio-group [(ngModel)]="edit.is_super">
        <label nz-radio [nzValue]="v.val" *ngFor="let v of isSuper">{{v.name}}</label>
      </nz-radio-group>
    </div>
  </div>
  <div nz-row class="item">
    <div nz-col nzSpan="2">角色：</div>
    <div nz-col nzSpan="22">
      <nz-select [(ngModel)]="edit.role_id">
        <nz-option [nzValue]="item._id" [nzLabel]="item.title" *ngFor="let item of role"></nz-option>
      </nz-select>
    </div>
  </div>
  <button nz-button nzType="primary" (click)="update()">{{edit._id ? '修改' : '添加'}}</button>
</nz-drawer>

